<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改供应商信息')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-supplier-edit" th:object="${jtSupplier}">
        <input name="supplierId" th:field="*{supplierId}" type="hidden">
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">[[#{supplier.name}]]：</label>
                <div class="col-sm-8">
                    <input name="supplierName" th:field="*{supplierName}" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{supplier.code}]]：</label>
                <div class="col-sm-8">
                    <input name="supplierCode" th:field="*{supplierCode}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{region}]]：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input name="countryRegion" th:value="*{countryRegion}"  id="suggest-country" class="form-control" type="text">
                        <div class="input-group-btn">
                            <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{currency}]]：</label>
                <div class="col-sm-8">
                    <input name="currency" th:field="*{currency}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{phoneNumber}]]：</label>
                <div class="col-sm-8">
                    <input name="countryCode" th:field="*{countryCode}" style="width: 70px;" class="input-line" type="number" maxlength="5" th:placeholder="#{countryCode}">
                    <span>-</span>
                    <input name="phoneNumber" th:field="*{phoneNumber}" class="input-line" type="number" style="width: 120px;" maxlength="11" th:placeholder="#{phoneNumber}">
                    <span class="label label-warning"><i class="fa fa-info-circle"></i>[[#{supplier.phone.tips}]]</span>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{contact}]]：</label>
                <div class="col-sm-8">
                    <input name="contact" th:field="*{contact}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{address}]]：</label>
                <div class="col-sm-8">
                    <input name="address" th:field="*{address}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label is-required">[[#{companyName}]]：</label>
                <div class="col-sm-8">
                    <input name="companyName" th:field="*{companyName}" class="form-control" type="text" required>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{taxNo}]]：</label>
                <div class="col-sm-8">
                    <input name="companyTaxNo" th:field="*{companyTaxNo}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{taxScale}]]：</label>
                <div class="col-sm-8">
                    <select name="taxScale" class="form-control" th:with="type=${@dict.getType('jt_tax_scale')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{taxScale}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{paymentMethod}]]：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('jt_supplier_payment_method')}">
                        <input type="radio" th:id="${'paymentMethod_' + dict.dictCode}" name="paymentMethod" th:value="${dict.dictValue}" th:field="*{paymentMethod}">
                        <label th:for="${'paymentMethod_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{nameOfAccount}]]：</label>
                <div class="col-sm-8">
                    <input name="nameOfAccount" th:field="*{nameOfAccount}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{bankOfDeposit}]]：</label>
                <div class="col-sm-8">
                    <input name="bankOfDeposit" th:field="*{bankOfDeposit}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{bankAccountNumber}]]：</label>
                <div class="col-sm-8">
                    <input name="bankAccountNumber" th:field="*{bankAccountNumber}" class="form-control" type="text">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{remark}]]：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control" rows="3">[[*{remark}]]</textarea>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{rating}]]：</label>
                <div class="col-sm-8">
                    <input th:field="*{rating}" class="form-control" type="number" min="0" max="100" placeholder="评级：0-100">
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{reasonForRating}]]：</label><!-- 评分说明 -->
                <div class="col-sm-8">
                    <textarea name="params[remark]" class="form-control" rows="3"></textarea>
                </div>
            </div>
        </div>
        <div class="col-xs-6">
            <div class="form-group">
                <label class="col-sm-4 control-label">[[#{status}]]：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-suggest-js" />
<script th:inline="javascript">
    var prefix = ctx + "business/supplier";
    $("#form-supplier-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-supplier-edit').serialize());
        }
    }

    var countryRegionSuggest = $("#suggest-country").bsSuggest({
        url: ctx + "business/country/select/list",
        idField: "countryId",
        keyField: "countryRegion",
        clearable: true,
        ignorecase: true,
        hideOnSelect: true,
        effectiveFields: ["countryId", "countryRegion","countryCode","currency"],
        effectiveFieldsAlias: {countryId: "地区ID", countryRegion: "地区", countryCode:'国家码', currency:'货币'},
    }).on('onSetSelectValue', function (e, selectedData, selectedRawData) {
        console.log('onSetSelectValue: ', selectedData);
        $("#countryRegion").val(selectedRawData.countryRegion);
        $("#countryCode").val(selectedRawData.countryCode);
        $("#currency").val(selectedRawData.currency);
    }).on('onUnsetSelectValue', function (e) {
        //console.log("onUnsetSelectValue=="+e);
        $("#countryRegion").val("");
        $("#countryCode").val("");
        $("#currency").val("");
    });
</script>
</body>
</html>